var globalData = {
server: "http://127.0.0.1:8080/",//302 没有权限  
pre: "http://127.0.0.1:8080/jxc/",
socket: "ws://localhost:8080/",
//把登陆的用户名存入h5的缓存
setUserInfo: function(name, token, id) {
      window.localStorage.setItem("username", name);
      window.localStorage.setItem("token", token);
      window.localStorage.setItem("uid", id);
},
setPer: function(plist) { //设置权限列表
      window.localStorage.setItem("plist", plist);
},
//把角色存入缓存中
  setUserRose: function(rose) {
    window.localStorage.setItem("rose", rose);
  },
  setUserRoseTime: function(time) {
    window.localStorage.setItem("time", time);
  },
hasPer: function(pvalue) {
      return window.localStorage.getItem("plist").includes(pvalue);
},
//从H5缓存中取出当前登录的用户名
getUserName: function() {
      return window.localStorage.getItem("username");
},
getToken: function() {
      return window.localStorage.getItem("token");
},
getPer: function() {
      return window.localStorage.getItem("plist");
},
getUid: function() {
      return window.localStorage.getItem("uid");
},
getUserRose: function() {
    return window.localStorage.getItem("rose");
  },
  getUserRoseTime: function() {
    return window.localStorage.getItem("time");
  },
//退出登录
loginOut: function() {
      globalData.setUserInfo(null, null, null);
      window.location.href = "login.html";
}
};
var a = globalData.getToken();
if(a == null || a == "null") {
var url = window.location.href;
if(url.indexOf("login.html") >= 0) {
 
} else {
      window.location.href = "login.html";
}
} else {
var url = window.location.href;
if(url.indexOf("login.html") >= 0) {
      window.location.href = "index.html";
}
}
